package com.ash.service;

import JavaAPI.HttpsPostRequest;
import JavaAPI.Receipt;
import com.ash.util.Config;
import com.ash.util.ConfigUtil;

public class TransactionService {


    private static TransactionService transactionService = new TransactionService();

    public static TransactionService getInstance() {
        return transactionService;
    }

    private TransactionService() {

    }

    public HttpsPostRequest getHttpsPostRequest() {
        Config config = ConfigUtil.getConfig();

        String storeId = config.getStoreId();
        String apiToken = config.getApiToken();
        Boolean testMode = config.getTestMode();
        boolean status_check = false;
        String procCountryCode = "CA";


        HttpsPostRequest mpgReq = new HttpsPostRequest();
        mpgReq.setProcCountryCode(procCountryCode);
        mpgReq.setStoreId(storeId);
        mpgReq.setApiToken(apiToken);
        mpgReq.setTestMode(testMode); //false or comment out this line for production transactions
        mpgReq.setStatusCheck(status_check);

        return mpgReq;
    }


    public void printResult(HttpsPostRequest mpgReq) {
        try {
            Receipt receipt = mpgReq.getReceipt();

            System.out.println("CardType = " + receipt.getCardType());
            System.out.println("TransAmount = " + receipt.getTransAmount());
            System.out.println("TxnNumber = " + receipt.getTxnNumber());
            System.out.println("ReceiptId = " + receipt.getReceiptId());
            System.out.println("TransType = " + receipt.getTransType());
            System.out.println("ReferenceNum = " + receipt.getReferenceNum());
            System.out.println("ResponseCode = " + receipt.getResponseCode());
            System.out.println("ISO = " + receipt.getISO());
            System.out.println("BankTotals = " + receipt.getBankTotals());
            System.out.println("Message = " + receipt.getMessage());
            System.out.println("AuthCode = " + receipt.getAuthCode());
            System.out.println("Complete = " + receipt.getComplete());
            System.out.println("TransDate = " + receipt.getTransDate());
            System.out.println("TransTime = " + receipt.getTransTime());
            System.out.println("Ticket = " + receipt.getTicket());
            System.out.println("TimedOut = " + receipt.getTimedOut());
            System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
            System.out.println("HostId = " + receipt.getHostId());
            System.out.println("IssuerId = " + receipt.getIssuerId());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
